<%@ page import="java.lang.annotation.Target" %>
    <%@ page import="com.ktjy.entity.UserAco" %>

        <%@ page contentType="text/html;charset=UTF-8" language="java" %>
            <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
                <html>

                <head>
                    <title>图书信息展示</title>
                    <style>
                        body {
                            font-family: Arial, sans-serif;
                            background-color: #f5f5f5;
                            margin: 0;
                            padding: 20px;
                        }

                        .container {
                            max-width: 1000px;
                            margin: 0 auto;
                            background-color: white;
                            padding: 20px;
                            border-radius: 8px;
                            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
                        }

                        h1 {
                            color: #333;
                            margin-bottom: 30px;
                            text-align: center;
                        }

                        .search-form {
                            margin-bottom: 20px;
                            text-align: center;
                        }

                        input[type="text"] {
                            padding: 8px;
                            border: 1px solid #ddd;
                            border-radius: 4px;
                            margin: 0 10px;
                            width: 200px;
                        }

                        input[type="submit"],
                        .btn {
                            background-color: #4CAF50;
                            color: white;
                            padding: 8px 15px;
                            border: none;
                            border-radius: 4px;
                            cursor: pointer;
                            text-decoration: none;
                            display: inline-block;
                        }

                        input[type="submit"]:hover,
                        .btn:hover {
                            background-color: #45a049;
                        }

                        table {
                            width: 100%;
                            border-collapse: collapse;
                            margin-top: 20px;
                        }

                        th,
                        td {
                            padding: 12px;
                            text-align: left;
                            border: 1px solid #ddd;
                        }

                        th {
                            background-color: #f8f8f8;
                            color: #333;
                        }

                        tr:nth-child(even) {
                            background-color: #f9f9f9;
                        }

                        tr:hover {
                            background-color: #f5f5f5;
                        }

                        .pagination {
                            margin-top: 20px;
                            text-align: center;
                        }

                        .pagination a {
                            color: #4CAF50;
                            padding: 8px 16px;
                            text-decoration: none;
                            border: 1px solid #ddd;
                            margin: 0 4px;
                        }

                        .pagination a:hover {
                            background-color: #f1f1f1;
                        }

                        .pagination a[hidden] {
                            display: none;
                        }

                        .action-links a {
                            color: #4CAF50;
                            text-decoration: none;
                            margin: 0 5px;
                        }

                        .action-links a:hover {
                            text-decoration: underline;
                        }

                        .add-book {
                            text-align: center;
                            margin-top: 20px;
                        }
                    </style>
                </head>

                <body>
                    <% UserAco user=(UserAco) session.getAttribute("user"); if(user==null){
                        response.sendRedirect("index.jsp"); } %>
                        <div class="container">
                            <h1>图书信息</h1>
                            <form action="bookList" method="get" class="search-form">
                                图书名称:<input type="text" name="bName" value="">
                                图书作者:<input type="text" name="bAuthor" value="">
                                <input type="submit" value="搜索">
                            </form>

                            <table>
                                <tr>
                                    <th>图书名称</th>
                                    <th>图书作者</th>
                                    <th>购买时间</th>
                                    <th>图书分类</th>
                                    <th>操作</th>
                                </tr>
                                <c:forEach var="book" items="${page.list}">
                                    <tr>
                                        <td>${book.bName}</td>
                                        <td>${book.bAuthor}</td>
                                        <td>${book.bTime}</td>
                                        <td>
                                            <c:if test="${book.bType==0}">计算机/软件</c:if>
                                            <c:if test="${book.bType==1}">小说/文摘</c:if>
                                            <c:if test="${book.bType==2}">杂项</c:if>
                                        </td>
                                        <td class="action-links">
                                            <a href="selectByIdBook?bid=${book.bid}">编辑</a>
                                            <a href="delete?bid=${book.bid}"
                                                onclick="return confirm('确定要删除这本书吗？')">删除</a>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </table>

                            <div class="pagination">
                                总记录数:${page.total} 当前页数${page.totalPage}/${page.page}总页数
                                <a href="bookList?totalPage=${page.totalPage-1}" <c:if
                                    test="${page.totalPage==1}">hidden</c:if>>上一页</a>
                                <a href="bookList?totalPage=${page.totalPage+1}" <c:if
                                    test="${page.totalPage==page.page}">hidden</c:if>>下一页</a>
                            </div>

                            <div class="add-book">
                                <a href="add" class="btn">新增图书</a>
                            </div>
                        </div>
                </body>
            </html>